package com.dongdongshop.controller;

import com.dongdongshop.api.SellerServiceApi;
import com.dongdongshop.data.Result;
import com.dongdongshop.page.PageParms;
import com.dongdongshop.page.PageUtil;
import com.dongdongshop.service.BrandService;
import com.dongdongshop.vo.BrandVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@RestController
@RequestMapping("brand")
public class BrandController {
    @Autowired
    private BrandService brandService;


    @PostMapping("getBrandList")
    public Result getBrandList(@RequestBody PageParms<BrandVO> page) {
        PageUtil pageUtil = brandService.getBrandList(page);
        return Result.OK().setData(pageUtil);
    }

    @PostMapping("addBrand")
    public Result addBrand(@RequestBody BrandVO brandVO) {
        brandService.addBrand(brandVO);
        return Result.OK();
    }

    @PostMapping("getBrankById/{id}")
    public Result getBrankById(@PathVariable("id") Long id) {
        BrandVO brandVO = brandService.getBrankById(id);
        return Result.OK().setData(brandVO);
    }

    @PostMapping("updateBrand")
    public Result updateBrand(@RequestBody BrandVO brandVO) {
        brandService.updateBrand(brandVO);
        return Result.OK();
    }

    @PostMapping("deleteBatch")
    public Result deleteBatch(@RequestBody List<Long> ids) {
        brandService.deleteBatch(ids);
        return Result.OK();
    }

    @PostMapping("getAllBrandList")
    public Result getAllBrandList() {
        List<BrandVO> brandVOList = brandService.getAllBrandList();
        return Result.OK().setData(brandVOList);
    }
}
